//
//  EventCenterCell.m
//  ConvenientlyTake
//
//  Created by 张奇 on 2022/12/20.
//

#import "EventCenterCell.h"
#import "EventCenterModel.h"
@interface EventCenterCell ()

@property (weak, nonatomic) IBOutlet UIView *contentBgView;

@property (weak, nonatomic) IBOutlet UILabel *eventCodeLabel;
@property (weak, nonatomic) IBOutlet QMUILabel *stateLabel;

@property (weak, nonatomic) IBOutlet UILabel *promoterNameLabel;
@property (weak, nonatomic) IBOutlet QMUILabel *jobLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *jobLabelMarginRight;

@property (weak, nonatomic) IBOutlet UILabel *eventTypeNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *addressLabel;
@property (weak, nonatomic) IBOutlet UILabel *originatingTimeLabel;
@property (weak, nonatomic) IBOutlet UILabel *disposalDeptNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *requiredDisposeCompletionTimeLabel;


@end

@implementation EventCenterCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.backgroundColor = UIColorForBackground;
    self.contentBgView.layer.cornerRadius = TableViewCornerRadius;
    self.contentBgView.layer.masksToBounds = YES;
    
    self.stateLabel.backgroundColor = RGB(232, 243, 255);
    self.stateLabel.contentEdgeInsets = UIEdgeInsetsMake(3, 6, 3, 6);
    self.stateLabel.layer.cornerRadius = 3;
    self.stateLabel.layer.masksToBounds = YES;
    
    self.jobLabel.contentEdgeInsets = UIEdgeInsetsMake(2, 4, 2, 4);
    self.jobLabel.layer.borderWidth = 0.5;
    self.jobLabel.layer.borderColor = RGB(0, 180, 42).CGColor;
    self.jobLabel.layer.cornerRadius = 2;
}

- (void)setEventModel:(EventCenterModel *)eventModel {
    _eventModel = eventModel;
    self.eventCodeLabel.text = eventModel.eventCode?:@"-";
    self.stateLabel.text = eventModel.eventStateName?:@"-";
    self.stateLabel.textColor = eventModel.getEventStateTextColor;
    self.stateLabel.backgroundColor = eventModel.getEventStateBgColor;
    self.eventTypeNameLabel.text = eventModel.eventTypeName?:@"-";
    self.promoterNameLabel.text = [NSString stringWithFormat:@"%@(%@)", R(eventModel.promoterName), R(eventModel.promoterPhone)];
    if (eventModel.promoterType == 2) {
        //考察组
        self.jobLabel.text = @"实地调查组";
        self.jobLabelMarginRight.constant = 12;
        self.jobLabel.hidden = NO;
    } else {
        //市民
        self.jobLabel.text = @"市民";
        self.jobLabelMarginRight.constant = 12;
        self.jobLabel.hidden = NO;
    }
    self.addressLabel.text = eventModel.address?:@"-";
    self.originatingTimeLabel.text = eventModel.originatingTime?:@"-";
    self.disposalDeptNameLabel.text = eventModel.disposalDeptName?:@"-";
    self.requiredDisposeCompletionTimeLabel.text = eventModel.requiredDisposeCompletionTime?:@"-";
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
